import type {Organization} from 'sentry/types/organization';

type BasePreprodBuildEvent = {
  organization: Organization;
  build_id?: string;
  platform?: string | null;
  project_slug?: string;
  project_type?: string | null;
};

export type PreprodBuildEventParameters = {
  'preprod.builds.compare.go_to_build_details': BasePreprodBuildEvent & {
    slot?: 'head' | 'base';
  };
  'preprod.builds.compare.select_base_build': BasePreprodBuildEvent;
  'preprod.builds.compare.trigger_comparison': BasePreprodBuildEvent;
  'preprod.builds.details.compare_build_clicked': BasePreprodBuildEvent;
  'preprod.builds.details.delete_build': BasePreprodBuildEvent;
  'preprod.builds.details.expand_insight': BasePreprodBuildEvent & {
    insight_key: string;
  };
  'preprod.builds.details.open_insight_details_modal': BasePreprodBuildEvent & {
    insight_key: string;
  };
  'preprod.builds.details.open_insights_sidebar': BasePreprodBuildEvent & {
    source: 'metric_card' | 'insight_table';
  };
  'preprod.builds.release.build_row_clicked': BasePreprodBuildEvent;
};

type PreprodBuildAnalyticsKey = keyof PreprodBuildEventParameters;

export const preprodBuildEventMap: Record<PreprodBuildAnalyticsKey, string | null> = {
  'preprod.builds.release.build_row_clicked': 'Preprod Builds: Release Build Row Clicked',
  'preprod.builds.details.open_insights_sidebar':
    'Preprod Build Details: Insights Sidebar Opened',
  'preprod.builds.details.expand_insight': 'Preprod Build Details: Insight Expanded',
  'preprod.builds.details.open_insight_details_modal':
    'Preprod Build Details: Open Insight Details Modal',
  'preprod.builds.details.delete_build': 'Preprod Build Details: Delete Build',
  'preprod.builds.details.compare_build_clicked':
    'Preprod Build Details: Compare Clicked',
  'preprod.builds.compare.go_to_build_details':
    'Preprod Build Comparison: Go to Build Details',
  'preprod.builds.compare.select_base_build': 'Preprod Build Comparison: Base Selected',
  'preprod.builds.compare.trigger_comparison':
    'Preprod Build Comparison: Compare Triggered',
};
